-
-
Notifications
You must be signed in to change notification settings - Fork 32
feat(status-roles): add cog to assign roles based on user status #789
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Reviewer's Guide by SourceryThis pull request introduces a new cog, Sequence diagram for status role assignmentsequenceDiagram
participant User
participant DiscordClient
participant StatusRolesCog
participant DiscordAPI
User->>DiscordClient: Updates status
DiscordClient->>StatusRolesCog: on_presence_update(before, after)
StatusRolesCog->>StatusRolesCog: get_custom_status(member)
StatusRolesCog->>StatusRolesCog: has_activity_changed(before, after)
StatusRolesCog->>StatusRolesCog: check_and_update_roles(member)
StatusRolesCog->>StatusRolesCog: get_custom_status(member)
StatusRolesCog->>StatusRolesCog: for each config in STATUS_ROLES
StatusRolesCog->>StatusRolesCog: re.search(pattern, status_text)
alt matches and not has_role
StatusRolesCog->>DiscordAPI: member.add_roles(role)
DiscordAPI-->>StatusRolesCog: Role added
else not matches and has_role
StatusRolesCog->>DiscordAPI: member.remove_roles(role)
DiscordAPI-->>StatusRolesCog: Role removed
end
File-Level Changes
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hey @electron271 - I've reviewed your changes - here's some feedback:
Overall Comments:
- Consider adding a more specific exception handler for
discord.Forbidden
to differentiate between missing permissions to add vs remove roles. - It might be helpful to include the server ID in the log messages for easier debugging.
Here's what I looked at during the review
- 🟡 General issues: 1 issue found
- 🟢 Security: all looks good
- 🟢 Testing: all looks good
- 🟡 Complexity: 1 issue found
- 🟢 Documentation: all looks good
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.
Co-authored-by: sourcery-ai[bot] <58596630+sourcery-ai[bot]@users.noreply.github.com>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
works, tested again
Description
add automatically giving roles based on status
Guidelines
My code follows the style guidelines of this project (formatted with Ruff)
I have performed a self-review of my own code
I have commented my code, particularly in hard-to-understand areas
I have made corresponding changes to the documentation if needed
My changes generate no new warnings
I have tested this change
Any dependent changes have been merged and published in downstream modules
I have added all appropriate labels to this PR
I have followed all of these guidelines.
How Has This Been Tested? (if applicable)
ran it with regex "test" and changed status
Summary by Sourcery
Adds a cog that automatically assigns roles to users based on their status, using regular expressions to match against the user's custom status. The cog checks and updates roles on startup and when a user's presence changes.
New Features: